package com.admin.kotlintest.activity

import android.support.v4.view.ViewPager
import cn.bmob.v3.BmobQuery
import cn.bmob.v3.BmobUser
import cn.bmob.v3.exception.BmobException
import cn.bmob.v3.listener.FindListener
import com.admin.kotlintest.R
import com.admin.kotlintest.adapter.TabRecordAdapter
import com.admin.kotlintest.base.BaseActivity
import com.admin.kotlintest.bean.Appointment
import com.admin.kotlintest.bean.MyUser
import com.admin.kotlintest.config.FixedValue
import com.admin.kotlintest.config.MyApplication
import com.admin.kotlintest.fragment.AppiontmentRecordFragment
import com.socks.library.KLog
import kotlinx.android.synthetic.main.activity_appiontment_record.*
import kotlinx.android.synthetic.main.layout_title.*

/**
 * Created by 吴昶 on 2018/4/20.
 */
class AppiontmentRecordActivity:BaseActivity(){

    var tabTitles=ArrayList<String>()
    var tabFragment=ArrayList<AppiontmentRecordFragment>()
    var tabAdapter:TabRecordAdapter?=null

    override fun bindLayout(): Int {
        return R.layout.activity_appiontment_record
    }

    override fun initData() {
        for(m in 0..4){
            var t=if(m==3){-1}else if(m==4){3}else{m}
            var fragment1=AppiontmentRecordFragment()
            fragment1.showDataType=t
            tabFragment.add(fragment1)
        }
        tabTitles.add("待处理")
        tabTitles.add("已签收")
        tabTitles.add("进行中")
        tabTitles.add("已拒绝")
        tabTitles.add("已完成")
        tv_title.text=tabTitles[0]
        tabAdapter= TabRecordAdapter(tabFragment,tabTitles,supportFragmentManager)
        vp_appiontment_state.adapter=tabAdapter
        table_state.setupWithViewPager(vp_appiontment_state)
    }

    override fun initEvent() {
        vp_appiontment_state.addOnPageChangeListener(object:ViewPager.OnPageChangeListener{
            override fun onPageScrollStateChanged(state: Int) {

            }

            override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) {

            }

            override fun onPageSelected(position: Int) {
                tv_title.text=tabTitles[position]
            }

        })
    }

}